cmake_minimum_required(VERSION 3.1)

project(monitorctl_test C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

option(DEBUG "Enable debug mode" OFF)
if(DEBUG)
    add_definitions(-DDEBUG -DDEBUG_TIME)
endif()

add_definitions(-DTESTING)

# 设置 CMake 模块路径
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")

# 查找 CUnit 库
find_package(CUnit REQUIRED)
include_directories(${CUNIT_INCLUDE_DIRS})

# 包含你的源文件
file(GLOB SOURCES
    "${PROJECT_SOURCE_DIR}/*.c"
    "${PROJECT_SOURCE_DIR}/../src/*.c"
)

# 移除不参与测试的文件（如 main.c）
list(REMOVE_ITEM SOURCES "${PROJECT_SOURCE_DIR}/../src/main.c")

include_directories(
    "${PROJECT_SOURCE_DIR}/../src"
    "${PROJECT_SOURCE_DIR}/.."
)

# 打印最终源文件列表（调试用）
message(STATUS "Sources: ${SOURCES}")

add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${CUNIT_LIBRARIES})